import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'

export const constantRoutes: RouteRecordRaw[] = [
  {
    path: '/redirect',
    component: () => import('@/views/system/layout/HSB/index.vue'),
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/system/redirect/index.vue'),
      },
    ],
  },
  {
    path: '/login',
    meta: {
      title: '登录',
    },
    component: () => import('@/views/system/auth/login/index.vue'),
  },
  {
    path: '/register',
    meta: {
      title: '注册',
    },
    component: () => import('@/views/system/auth/register/index.vue'),
  },
  {
    path: '/:pathMatch(.*)*',
    meta: {
      title: '404',
    },
    component: () => import('@/views/system/error/404.vue'),
  },
  {
    path: '/401',
    meta: {
      title: '401',
    },
    component: () => import('@/views/system/error/401.vue'),
  },
  {
    path: '/',
    redirect: '/globalStatistics',
    component: () => import('@/views/system/layout/HSB/index.vue'),
    children: [
      {
        path: 'globalStatistics',
        meta: {
          title: '全局监管',
        },
        component: () => import('@/views/globalStatistics/layout.vue'),
        redirect: '/globalStatistics/company',
        children: [
          // 公司-首页
          {
            path: 'company',
            meta: {
              title: '全局监管',
            },
            component: () => import('@/views/globalStatistics/pages/company/index.vue'),
          },
          // 公司下工程
          {
            path: 'project',
            meta: {
              title: '全局监管',
            },
            component: () => import('@/views/globalStatistics/pages/project/index.vue'),
          },
          // 可能的标段。变电站
          {
            path: 'section',
            meta: {
              title: '全局监管',
            },
            component: () => import('@/views/globalStatistics/pages/section/index.vue'),
          },
        ],
      },
      {
        path: 'questionAnalyse',
        meta: {
          title: '问题分析',
        },
        component: () => import('@/views/questionAnalyse/index.vue'),
      },
      {
        path: 'questionList',
        meta: {
          title: '问题清单',
        },
        component: () => import('@/views/questionList/index.vue'),
      },
      {
        path: 'dataManage',
        meta: {
          title: '数据管理',
        },
        component: () => import('@/views/dataManage/index.vue'),
      },
    ],
  },
]

// 动态路由，基于用户权限动态去加载
export const dynamicRoutes = []

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: constantRoutes,
})

export default router
